# -*- coding: utf-8 -*-

def test01():
    lst = [88,89,90,98,00,99]
    print("原列表:", lst)

    new_lst = []
    for item in lst:
        if item == 00:
            new_item = '200' + str(item)
            new_lst.append(new_item)
        else:
            new_lst.append('19' + str(item))

    print("新列表:", new_lst)

def test02():
    user_input = ''
    good_dic = {}
    user_shop_car = []
    while( user_input != 'q'):
        user_input = input("请输入商品的编号和商品的名称进行商品入库，每次只能输入一件商品（q退出录入）：")
        if user_input == 'q':
            break
        else:
            # 按空格分割用户输入的字符串
            user_input = user_input.split(' ')
            good_dic[user_input[0]] = user_input[1]

    print("商品录入成功：")
    for key, value in good_dic.items():
        print("商品编号：", key, "商品名称：", value)

    user_input = ''

    dic_keys = good_dic.keys()
    while(user_input != 'q'):
        user_input = input("请输入要购买的商品编号（q退出购买）：")
        if user_input == 'q':
            break
        else:
            if user_input in dic_keys:
                car_item_dic = {user_input: good_dic[user_input]}
                user_shop_car.append(car_item_dic)
                print("商品已成功添加至购物车")
            else:
                print("商品不存在，请重新输入")

    print("-" * 50)
    print("您购物车里已选择的商品为：")
    for item in user_shop_car:
        for key,value in item.items():
            print("商品编号：", key, "商品名称：", value)


def test03():
    user_input = input("请输入一个字符串：")
    split = user_input.split(' ')
    print(split)

def test04():
    dic1 = {'1001': 'apple'}
    dic2 = {'1002': 'banana'}
    dic3 = {'1003': 'orange'}
    lst = [dic1, dic2, dic3]

    for item in lst:
        for key, value in item.items():
            print("商品编号：", key, "商品名称：", value)

def test05():
    train_dic = {}
    lst_G1569 = ("北京南-天津南", "18:06", "18:39", "00:33")
    lst_G1567 = ("北京南-天津南", "18:15", "18:49", "00:34")
    lst_G8917 = ("北京南-天津西", "18:20", "19:19", "00:59")
    lst_G203 = ("北京南-天津南", "18:35", "19:09", "00:34")
    train_dic['G1569'] = lst_G1569
    train_dic['G1567'] = lst_G1567
    train_dic['G8917'] = lst_G8917
    train_dic['G203'] = lst_G203

    print("车次",'\t',"出发站-到达站",'\t',"出发时间",'\t',"到达时间",'\t',"历时时长")
    for key, value in train_dic.items():
        print(key,'\t', value[0],'\t', value[1],'\t', value[2],'\t', value[3])

    train_num = input("请输入要购买的车次: ")
    train_person_names = input("请输入乘车人姓名，如果是多位乘车人使用逗号分隔: ")

    train_info = train_dic[train_num]

    print("您已购买了", train_num, " ", train_info[0], train_info[1] + "开，请" + train_person_names + "尽快换取纸质车票。【铁路客服】")





if __name__ == '__main__':
    # test01()
    # test02()
    # test03()
    # test04()
    test05()

